package Thread;

/**
 * 使用饿汉模式实现单例模式
 */
class  Singleton {
    String name;
    int age;
    private  static  Singleton instance = new Singleton();
    public  static  Singleton getInstance(){
        return instance;
    }
    private  Singleton(){

    }
    private  Singleton(int n){

    }

}
public class Demo24 {
    public static void main(String[] args) {
        Singleton s1 = Singleton.getInstance();
        Singleton s2 = Singleton.getInstance();
        System.out.println(s1==s2);
        //Singleton t = new Singleton();

    }
}
